package zl.Dao;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.springframework.stereotype.Repository;
import zl.Entity.Animal;
import zl.Untils.HibernateUtil;

import java.util.List;

@Repository
public class AnimalDao {
    public List<Animal> selectAll(){
        Session session= HibernateUtil.openSession();
        Transaction tx=session.beginTransaction();
        String hql="from Animal";
        List<Animal> list=session.createQuery(hql,Animal.class).list();
        tx.commit();
        HibernateUtil.closeSession();
        return list;
    }
}
